<?php

namespace app\admin\controller;

use app\common\model\Classes;
use app\common\model\StudentKaoqinRemark as StudentKaoqinRemarkModel;
use app\common\model\Student as StudentModel;

class Studentkaoqinremark extends Base
{


    /**
     * 列表
     * @return \think\response\Json
     */
    public function remark_list()
    {
        if (request()->isPost()) {
            $page = input('page', 1);
            $size = input('size', 20);
            $where = [];
            $list = StudentKaoqinRemarkModel::getPage($where, $page, $size, 'status asc,id desc');
            foreach ($list as $key => $value) {
                $list[$key]['class_name'] = Classes::getValue(['id' => ['eq', $value['cid']]], 'name');
                $list[$key]['student_name'] = StudentModel::getValue(['id' => ['eq', $value['sid']]], 'name');
            }
            $total = StudentKaoqinRemarkModel::getCount($where);
            return returnJson(200, '', compact('page', 'size', 'list', 'total'));
        }
    }

    public function shenhe()
    {
        if (request()->isPost()) {
            $where = [
                'id' => ['eq', input('id')]
            ];
            $save = [
                'status' => 2,
                'update_time' => time()
            ];
            StudentKaoqinRemarkModel::update($save,$where);
            return returnJson(200, '审核成功');
        }
    }

}

